package pl.szpadel.android.gadu;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/// Broadcast receiver used to start service on system boot
public class BootReceiver extends BroadcastReceiver {
	
	private static final String TAG = "BootReceiver";

	@Override
	public void onReceive(Context ctx, Intent intent) {
		AGLog.d(TAG, "Event received, creating app...");
		
        App.createInstance(ctx);

        AGLog.d(TAG, "Reading config: do we want to start on boot?");
        
        // start servixe if config allows for it
        if (App.getInstance().getConfig().getStartOnBoot()){
            AGLog.d(TAG, "Reading config: yes we want to start on boot, starting service");
        	ctx.startService(new Intent(ctx, CommunicationService.class));
        }
	}

}
